string=input()
array=string.split()
numbers=['zero','one','two','three','four','five','six','seven','eight','nine']
flag = True
def check_number(val):
    if val%2==0:
        return False
    for i in range(2,val//2+2):
        if val%i==0:
            return False
    return True
def result(val):
        vmin=val
        vmax=val
        if check_number(val)==True:
            return val
        else:
            while True:
                if check_number(vmin)==True:
                    return vmin
                elif check_number(vmax)==True:
                    return vmax
                else:
                    vmin-=1
                    vmax+=1

if array[0]==numbers[0] or len(array)<3:
    flag=False
for i in array:
    if i not in numbers:
        flag=False
if flag==True:
    res_number=0
    res_number+=100*numbers.index(array[0])
    res_number+=10*numbers.index(array[1])
    res_number+=numbers.index(array[2])
    print(result(res_number))
else:
    print( "Wrong input")